package cn.dkk.structure_design.flyweight;

import cn.dkk.structure_design.flyweight.pojo.AbstractBox;
import cn.dkk.structure_design.flyweight.pojo.BoxFactory;

/**
 * @author dkk
 * @date 2022/7/19
 * @desc 享元模式测试代码
 */
public class Test {
    public static void main(String[] args) {
        BoxFactory box1 = BoxFactory.getBoxFactory();
        AbstractBox ibox = box1.getBox("I");
        ibox.display("红色");
        BoxFactory box2 = BoxFactory.getBoxFactory();
        AbstractBox ibox1 = box1.getBox("I");
        ibox.display("蓝色");
        System.out.println(ibox == ibox1);
    }
}
